package oom;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

/**
 * @Author ZhangCuirong
 * @Date 2025/10/9 14:38
 * @description:
 */
public class OOMTest {
    public static List<Object> list = new ArrayList<>();

    // JVM设置 idea 在虚拟机选项中设置
    // -Xms5M -Xmx5M -XX:+PrintGCDetails -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=./jvm.dump
    //jvisualvm
    public static void main(String[] args) {
        List<Object> list = new ArrayList<>();
        int i = 0;
        int j = 0;
        while (true) {
            //往list 中不停放入student 对象直到OOM
            list.add(new Student(i++, UUID.randomUUID().toString()));
            new Student(j--, UUID.randomUUID().toString());
        }
    }
}
